/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CustomerFrame.java
 *
 * Created on Feb 4, 2011, 3:18:08 PM
 */

package gbbmgmt;

import java.util.*;
import org.jdesktop.application.Action;
import javax.swing.JOptionPane;


/**
 *
 * @author dchapman
 */
public class CustomerFrame extends javax.swing.JFrame {

    public ArrayList<String[]> Customers;


    /** Creates new form CustomerFrame */
    public CustomerFrame() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jButtonCustPrev = new javax.swing.JButton();
        jButtonCustFirst = new javax.swing.JButton();
        jButtonCustAdd = new javax.swing.JButton();
        jButtonCustNext = new javax.swing.JButton();
        jButtonCustLast = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jTextFieldCustID = new javax.swing.JTextField();
        jTextFieldCustName = new javax.swing.JTextField();
        jTextFieldCustAddr = new javax.swing.JTextField();
        jTextFieldCustCity = new javax.swing.JTextField();
        jTextFieldCustState = new javax.swing.JTextField();
        jTextFieldCustZip = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        jTextFieldCustContact = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jTextFieldCustPhone = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jTextFieldEMail = new javax.swing.JTextField();
        jSeparator3 = new javax.swing.JSeparator();
        jLabel10 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jLabel11 = new javax.swing.JLabel();
        jRadioButton30 = new javax.swing.JRadioButton();
        jRadioButton15 = new javax.swing.JRadioButton();
        jRadioButton0 = new javax.swing.JRadioButton();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator4 = new javax.swing.JSeparator();
        jButton1 = new javax.swing.JButton();
        jButtonExit = new javax.swing.JButton();
        jButtonSubNewCust = new javax.swing.JButton();
        jButtonDelete = new javax.swing.JButton();
        jComboBoxCustomers = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N
        addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                formFocusGained(evt);
            }
        });

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(gbbmgmt.GBBMGMTApp.class).getContext().getActionMap(CustomerFrame.class, this);
        jButtonCustPrev.setAction(actionMap.get("GetPrev")); // NOI18N
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(gbbmgmt.GBBMGMTApp.class).getContext().getResourceMap(CustomerFrame.class);
        jButtonCustPrev.setText(resourceMap.getString("jButtonCustPrev.text")); // NOI18N
        jButtonCustPrev.setName("jButtonCustPrev"); // NOI18N

        jButtonCustFirst.setAction(actionMap.get("FirstRecord")); // NOI18N
        jButtonCustFirst.setText(resourceMap.getString("jButtonCustFirst.text")); // NOI18N
        jButtonCustFirst.setName("jButtonCustFirst"); // NOI18N

        jButtonCustAdd.setAction(actionMap.get("CreateNewCust")); // NOI18N
        jButtonCustAdd.setText(resourceMap.getString("jButtonCustAdd.text")); // NOI18N
        jButtonCustAdd.setName("jButtonCustAdd"); // NOI18N

        jButtonCustNext.setAction(actionMap.get("GetNext")); // NOI18N
        jButtonCustNext.setText(resourceMap.getString("jButtonCustNext.text")); // NOI18N
        jButtonCustNext.setName("jButtonCustNext"); // NOI18N

        jButtonCustLast.setAction(actionMap.get("LastRecord")); // NOI18N
        jButtonCustLast.setText(resourceMap.getString("jButtonCustLast.text")); // NOI18N
        jButtonCustLast.setName("jButtonCustLast"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jTextFieldCustID.setEditable(false);
        jTextFieldCustID.setText(resourceMap.getString("jTextFieldCustID.text")); // NOI18N
        jTextFieldCustID.setName("jTextFieldCustID"); // NOI18N

        jTextFieldCustName.setText(resourceMap.getString("jTextFieldCustName.text")); // NOI18N
        jTextFieldCustName.setName("jTextFieldCustName"); // NOI18N

        jTextFieldCustAddr.setText(resourceMap.getString("jTextFieldCustAddr.text")); // NOI18N
        jTextFieldCustAddr.setName("jTextFieldCustAddr"); // NOI18N

        jTextFieldCustCity.setText(resourceMap.getString("jTextFieldCustCity.text")); // NOI18N
        jTextFieldCustCity.setName("jTextFieldCustCity"); // NOI18N

        jTextFieldCustState.setText(resourceMap.getString("jTextFieldCustState.text")); // NOI18N
        jTextFieldCustState.setName("jTextFieldCustState"); // NOI18N

        jTextFieldCustZip.setText(resourceMap.getString("jTextFieldCustZip.text")); // NOI18N
        jTextFieldCustZip.setName("jTextFieldCustZip"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jSeparator2.setName("jSeparator2"); // NOI18N

        jTextFieldCustContact.setText(resourceMap.getString("jTextFieldCustContact.text")); // NOI18N
        jTextFieldCustContact.setName("jTextFieldCustContact"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jTextFieldCustPhone.setText(resourceMap.getString("jTextFieldCustPhone.text")); // NOI18N
        jTextFieldCustPhone.setName("jTextFieldCustPhone"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jTextFieldEMail.setText(resourceMap.getString("jTextFieldEMail.text")); // NOI18N
        jTextFieldEMail.setName("jTextFieldEMail"); // NOI18N

        jSeparator3.setName("jSeparator3"); // NOI18N

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jTextArea1.setName("jTextArea1"); // NOI18N
        jScrollPane1.setViewportView(jTextArea1);

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        buttonGroup1.add(jRadioButton30);
        jRadioButton30.setText(resourceMap.getString("jRadioButton30.text")); // NOI18N
        jRadioButton30.setName("jRadioButton30"); // NOI18N

        buttonGroup1.add(jRadioButton15);
        jRadioButton15.setText(resourceMap.getString("jRadioButton15.text")); // NOI18N
        jRadioButton15.setName("jRadioButton15"); // NOI18N

        buttonGroup1.add(jRadioButton0);
        jRadioButton0.setText(resourceMap.getString("jRadioButton0.text")); // NOI18N
        jRadioButton0.setName("jRadioButton0"); // NOI18N

        jSeparator1.setName("jSeparator1"); // NOI18N

        jSeparator4.setName("jSeparator4"); // NOI18N

        jButton1.setAction(actionMap.get("ModifyRecord")); // NOI18N
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N

        jButtonExit.setAction(actionMap.get("CustomerExit")); // NOI18N
        jButtonExit.setText(resourceMap.getString("jButtonExit.text")); // NOI18N
        jButtonExit.setName("jButtonExit"); // NOI18N

        jButtonSubNewCust.setAction(actionMap.get("SubmitEntry")); // NOI18N
        jButtonSubNewCust.setText(resourceMap.getString("jButtonSubNewCust.text")); // NOI18N
        jButtonSubNewCust.setName("jButtonSubNewCust"); // NOI18N

        jButtonDelete.setAction(actionMap.get("DeleteEntry")); // NOI18N
        jButtonDelete.setText(resourceMap.getString("jButtonDelete.text")); // NOI18N
        jButtonDelete.setName("jButtonDelete"); // NOI18N

        jComboBoxCustomers.setName("jComboBoxCustomers"); // NOI18N
        jComboBoxCustomers.addPopupMenuListener(new javax.swing.event.PopupMenuListener() {
            public void popupMenuCanceled(javax.swing.event.PopupMenuEvent evt) {
            }
            public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {
                jComboBoxCustomersPopupMenuWillBecomeInvisible(evt);
            }
            public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jComboBoxCustomers, 0, 317, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonCustFirst)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonCustPrev)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonCustNext)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonCustLast)
                .addContainerGap())
            .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jSeparator4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 531, Short.MAX_VALUE)
                    .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 531, Short.MAX_VALUE)
                    .addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 531, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel8)
                                    .addComponent(jLabel7))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jTextFieldCustPhone, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jLabel9)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jTextFieldEMail, javax.swing.GroupLayout.DEFAULT_SIZE, 228, Short.MAX_VALUE))
                                    .addComponent(jTextFieldCustContact, javax.swing.GroupLayout.DEFAULT_SIZE, 434, Short.MAX_VALUE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jLabel10)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 479, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jRadioButton30)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jRadioButton15)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jRadioButton0)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 166, Short.MAX_VALUE)
                                .addComponent(jButtonSubNewCust))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel2))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextFieldCustID, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTextFieldCustAddr, javax.swing.GroupLayout.DEFAULT_SIZE, 453, Short.MAX_VALUE)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addComponent(jTextFieldCustCity, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jLabel5)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jTextFieldCustState, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jLabel6)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jTextFieldCustZip, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jTextFieldCustName, javax.swing.GroupLayout.DEFAULT_SIZE, 453, Short.MAX_VALUE))))))
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonCustAdd)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonDelete)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 67, Short.MAX_VALUE)
                .addComponent(jButtonExit)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jButtonCustPrev)
                    .addComponent(jButtonCustFirst)
                    .addComponent(jButtonCustNext)
                    .addComponent(jButtonCustLast)
                    .addComponent(jComboBoxCustomers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 5, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldCustID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGap(9, 9, 9)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldCustName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTextFieldCustAddr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTextFieldCustZip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(jTextFieldCustState, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(jTextFieldCustCity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 8, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jTextFieldCustContact, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(14, 14, 14)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jTextFieldCustPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(jTextFieldEMail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 5, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jRadioButton30)
                        .addComponent(jLabel11)
                        .addComponent(jRadioButton15)
                        .addComponent(jRadioButton0))
                    .addComponent(jButtonSubNewCust))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 5, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButtonExit)
                    .addComponent(jButtonCustAdd)
                    .addComponent(jButtonDelete))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_formFocusGained
        // TODO add your handling code here:
    }//GEN-LAST:event_formFocusGained

    private void jComboBoxCustomersPopupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {//GEN-FIRST:event_jComboBoxCustomersPopupMenuWillBecomeInvisible
        // TODO add your handling code here:
        String Itm = jComboBoxCustomers.getSelectedItem().toString();

        for(String s[] : Customers){
            if (s[1].equals(Itm)) {
                DBA.openDBCon();
                DBA.GetCustomerData(s[0]);
                DBA.closeDBCon();
            }
        }

        SetData();
    }//GEN-LAST:event_jComboBoxCustomersPopupMenuWillBecomeInvisible

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new CustomerFrame().setVisible(true);
            }
        });
    }

    public void LoadList(){
        DBA.openDBCon();
        Customers = DBA.RunSQLQuery("SELECT CId,CName FROM Customer");
        DBA.closeDBCon();

        for(String s[] : Customers){
            jComboBoxCustomers.addItem(s[1]);
        }    
        
        FirstRecord();
    }

    public void SetData(){
        jTextFieldCustID.setText(Integer.toString(DBA.CId));
        jTextFieldCustName.setText(DBA.CName);
        jTextFieldCustAddr.setText(DBA.CAddr);
        jTextFieldCustCity.setText(DBA.CCity);
        jTextFieldCustContact.setText(DBA.CContact);
        jTextFieldCustPhone.setText(DBA.CPhone);
        jTextFieldCustState.setText(DBA.CState);
        jTextFieldCustZip.setText(Integer.toString(DBA.CZip));
        jTextFieldEMail.setText(DBA.CEmail);
        jTextArea1.setText(DBA.CNotes);
        if (DBA.CTerms == 0){
            jRadioButton0.setSelected(true);
        }
        if (DBA.CTerms == 15){
            //SET 15 Days
            jRadioButton15.setSelected(true);
        }
        if (DBA.CTerms == 30){
            //SET 30 Days
            jRadioButton30.setSelected(true);
        }

        jButtonSubNewCust.setVisible(false);
    }

    @Action
    public void LastRecord() {
        jComboBoxCustomers.setSelectedIndex(jComboBoxCustomers.getItemCount()-1);

        String Itm = jComboBoxCustomers.getSelectedItem().toString();

        for(String s[] : Customers){
            if (s[1].equals(Itm)) {
                DBA.openDBCon();
                DBA.GetCustomerData(s[0]);
                DBA.closeDBCon();
            }
        }
        SetData();
    }

    @Action
    public void FirstRecord() {
        jComboBoxCustomers.setSelectedIndex(0);

        String Itm = jComboBoxCustomers.getSelectedItem().toString();

        for(String s[] : Customers){
            if (s[1].equals(Itm)) {
                DBA.openDBCon();
                DBA.GetCustomerData(s[0]);
                DBA.closeDBCon();
            }
        }
        SetData();
    }

    @Action
    public void GetPrev() {
        if(jComboBoxCustomers.getSelectedIndex()>=1){
            jComboBoxCustomers.setSelectedIndex(jComboBoxCustomers.getSelectedIndex()-1);
        }

        String Itm = jComboBoxCustomers.getSelectedItem().toString();

        for(String s[] : Customers){
            if (s[1].equals(Itm)) {
                DBA.openDBCon();
                DBA.GetCustomerData(s[0]);
                DBA.closeDBCon();
            }
        }
        SetData();
    }

    @Action
    public void GetNext() {
        if(jComboBoxCustomers.getSelectedIndex() <= (jComboBoxCustomers.getItemCount()-2)){
            jComboBoxCustomers.setSelectedIndex(jComboBoxCustomers.getSelectedIndex()+1);
        }

        String Itm = jComboBoxCustomers.getSelectedItem().toString();

        for(String s[] : Customers){
            if (s[1].equals(Itm)) {
                DBA.openDBCon();
                DBA.GetCustomerData(s[0]);
                DBA.closeDBCon();
            }
        }
        SetData();
    }

    @Action
    public void ModifyRecord() {
        //TODO: Look for changes on this page and update the entry in the database.
        int response = JOptionPane.showConfirmDialog(null, 
                "This will modify customer data, continue?",
                "Warning",JOptionPane.WARNING_MESSAGE);
       
        if (response == 0){
            //User wants to update database, check for differences.
            DBA.openDBCon();
            String CustID = jTextFieldCustID.getText();

            if(!jTextFieldCustName.getText().equals(DBA.CName)){
                String query = "UPDATE Customer SET CName = '" +
                        jTextFieldCustName.getText() + "'WHERE CId = '" +
                        CustID + "'";
                DBA.RunSQLUpdateQuery(query);
            }
            if(!jTextFieldCustAddr.getText().equals(DBA.CAddr)){
                String query = "UPDATE Customer SET CAddr = '" +
                        jTextFieldCustAddr.getText() + "'WHERE CId = '" +
                        CustID + "'";
                DBA.RunSQLUpdateQuery(query);
            }
            if(!jTextFieldCustCity.getText().equals(DBA.CCity)){
                String query = "UPDATE Customer SET CCity = '" +
                        jTextFieldCustCity.getText() + "'WHERE CId = '" +
                        CustID + "'";
                DBA.RunSQLUpdateQuery(query);
            }
            if(!jTextFieldCustContact.getText().equals(DBA.CContact)){
                String query = "UPDATE Customer SET CContact = '" +
                        jTextFieldCustContact.getText() + "'WHERE CId = '" +
                        CustID + "'";
                DBA.RunSQLUpdateQuery(query);
            }
            if(!jTextFieldCustPhone.getText().equals(DBA.CPhone)){
                String query = "UPDATE Customer SET CPhone = '" +
                        jTextFieldCustPhone.getText() + "'WHERE CId = '" +
                        CustID + "'";
                DBA.RunSQLUpdateQuery(query);
            }
            if(!jTextFieldCustState.getText().equals(DBA.CState)){
                String query = "UPDATE Customer SET CState = '" +
                        jTextFieldCustState.getText() + "'WHERE CId = '" +
                        CustID + "'";
                DBA.RunSQLUpdateQuery(query);
            }
            if(!jTextFieldCustZip.getText().equals(Integer.toString(DBA.CZip))){
                String query = "UPDATE Customer SET CZip = '" +
                        jTextFieldCustZip.getText() + "'WHERE CId = '" +
                        CustID + "'";
                DBA.RunSQLUpdateQuery(query);
            }
            if(!jTextArea1.getText().equals(DBA.CNotes)){
                String query = "UPDATE Customer SET CNotes = '" +
                        jTextArea1.getText() + "'WHERE CId = '" +
                        CustID + "'";
                DBA.RunSQLUpdateQuery(query);
            }
            if(!jTextFieldEMail.getText().equals(DBA.CEmail)){
                String query = "UPDATE Customer SET CEmail = '" +
                        jTextFieldEMail.getText() + "'WHERE CId = '" +
                        CustID + "'";
                DBA.RunSQLUpdateQuery(query);
            }

            //Now check radio buttons.
            if(jRadioButton30.isSelected() && (DBA.CTerms != 30)){
                String query = "UPDATE Customer SET CTerms = '30' WHERE CId = '" +
                        CustID + "'";
                DBA.RunSQLUpdateQuery(query);
            }
            if(jRadioButton15.isSelected() && (DBA.CTerms != 15)){
                String query = "UPDATE Customer SET CTerms = '15' WHERE CId = '" +
                        CustID + "'";
                DBA.RunSQLUpdateQuery(query);
            }
            if(jRadioButton0.isSelected() && (DBA.CTerms != 0)){
                String query = "UPDATE Customer SET CTerms = '0' WHERE CId = '" +
                        CustID + "'";
                DBA.RunSQLUpdateQuery(query);
            }

            //Update screen with new info.
            DBA.GetCustomerData(CustID);
            DBA.closeDBCon();

            SetData();
        }

    }

    @Action
    public void CustomerExit() {
        dispose();
    }

    @Action
    public void CreateNewCust() {

        //set which buttons should be visible.
        jButtonSubNewCust.setVisible(true);
        jButtonCustAdd.setVisible(false);
        jButtonCustFirst.setVisible(false);
        jButtonCustLast.setVisible(false);
        jButtonCustNext.setVisible(false);
        jButtonCustPrev.setVisible(false);
        jButton1.setVisible(false);
        jComboBoxCustomers.setVisible(false);
        jTextFieldCustID.setVisible(false);
        jButtonDelete.setVisible(false);

        //reset all text fields.
        jTextFieldCustName.setText("");
        jTextFieldCustAddr.setText("");
        jTextFieldCustCity.setText("");
        jTextFieldCustContact.setText("");
        jTextFieldCustPhone.setText("");
        jTextFieldCustState.setText("");
        jTextFieldCustZip.setText("");
        jTextFieldEMail.setText("");
        jTextArea1.setText("");
        jRadioButton30.setSelected(true);

        /*NewCustomer newFrame = new NewCustomer();
        newFrame = new NewCustomer();
        newFrame.pack();
        newFrame.setLocation(250,250);
        newFrame.setVisible(true);
        newFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        newFrame.SetDefaults();*/
    }

    @Action
    public void SubmitEntry() {
        String Terms = "30";

        if (jRadioButton15.isSelected()){
            Terms = "15";
        }
        if (jRadioButton0.isSelected()){
            Terms = "0";
        }

        String query = "'" +
                jTextFieldCustName.getText() + "','" +
                jTextFieldCustAddr.getText() + "','" +
                jTextFieldCustCity.getText() + "','" +
                jTextFieldCustState.getText() + "','" +
                jTextFieldCustZip.getText() + "','" +
                jTextFieldCustContact.getText() + "','" +
                jTextFieldCustPhone.getText() + "','" +
                jTextArea1.getText() + "','" +
                jTextFieldEMail.getText() + "','" +
                Terms + "'";

        String fields = "CName,CAddr,CCity,CState,CZip,CContact,CPhone,CNotes,CEmail,CTerms";

        if(jTextFieldCustName.getText().equals("") ||
                jTextFieldCustAddr.getText().equals("") ||
                jTextFieldCustCity.getText().equals("") ||
                jTextFieldCustState.getText().equals("") ||
                jTextFieldCustZip.getText().equals("")){
            //Required fields are not set.
            JOptionPane.showMessageDialog(null,
                    "Customer Name, Address, City, State and Zip must be entered!",
                    "Error",JOptionPane.ERROR_MESSAGE);
        } else {
            //Enter information into database.
            DBA.openDBCon();
            DBA.RunSQLInsertQuery("Customer",fields,query);
            DBA.closeDBCon();
        }

        //set which buttons should be visible.
        jButtonSubNewCust.setVisible(false);
        jButtonCustAdd.setVisible(true);
        jButtonCustFirst.setVisible(true);
        jButtonCustLast.setVisible(true);
        jButtonCustNext.setVisible(true);
        jButtonCustPrev.setVisible(true);
        jButton1.setVisible(true);
        jComboBoxCustomers.setVisible(true);
        jTextFieldCustID.setVisible(true);
        jButtonDelete.setVisible(true);

        jComboBoxCustomers.removeAllItems();
        LoadList();
        LastRecord();
    }

    @Action
    public void DeleteEntry() {
        String query = "DELETE FROM Customer WHERE Cid = '"
                + jTextFieldCustID.getText() + "'";
        int response = JOptionPane.showConfirmDialog(null,
                "Do you want to delete this entry from the Database?",
                "Warning",JOptionPane.WARNING_MESSAGE);
        if (response == 0){
            DBA.openDBCon();
            DBA.RunSQLUpdateQuery(query);
            DBA.closeDBCon();
            jComboBoxCustomers.removeAllItems();
            LoadList();
            LastRecord();
        }
    }

    public void SelectEntry(String CustName){

        jComboBoxCustomers.setSelectedItem(CustName);

        String Itm = jComboBoxCustomers.getSelectedItem().toString();

        for(String s[] : Customers){
            if (s[1].equals(Itm)) {
                DBA.openDBCon();
                DBA.GetCustomerData(s[0]);
                DBA.closeDBCon();
            }
        }
        SetData();

        jButtonCustFirst.setVisible(false);
        jButtonCustLast.setVisible(false);
        jButtonCustNext.setVisible(false);
        jButtonCustPrev.setVisible(false);
        jButtonDelete.setVisible(false);
        jButtonCustAdd.setVisible(false);
        jButton1.setVisible(false);
        jComboBoxCustomers.setVisible(false);
    }



    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButtonCustAdd;
    private javax.swing.JButton jButtonCustFirst;
    private javax.swing.JButton jButtonCustLast;
    private javax.swing.JButton jButtonCustNext;
    private javax.swing.JButton jButtonCustPrev;
    private javax.swing.JButton jButtonDelete;
    private javax.swing.JButton jButtonExit;
    private javax.swing.JButton jButtonSubNewCust;
    private javax.swing.JComboBox jComboBoxCustomers;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JRadioButton jRadioButton0;
    private javax.swing.JRadioButton jRadioButton15;
    private javax.swing.JRadioButton jRadioButton30;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextField jTextFieldCustAddr;
    private javax.swing.JTextField jTextFieldCustCity;
    private javax.swing.JTextField jTextFieldCustContact;
    private javax.swing.JTextField jTextFieldCustID;
    private javax.swing.JTextField jTextFieldCustName;
    private javax.swing.JTextField jTextFieldCustPhone;
    private javax.swing.JTextField jTextFieldCustState;
    private javax.swing.JTextField jTextFieldCustZip;
    private javax.swing.JTextField jTextFieldEMail;
    // End of variables declaration//GEN-END:variables

}
